package com.fish.service.passport;

import com.fish.passport.dao.PassCodeDAO;
import com.fish.passport.dao.PassEventDAO;
import com.fish.passport.dao.PassPortCodeDAO;
import com.fish.passport.po.PassCode;
import com.fish.passport.po.PassEvent;
import com.fish.system.dao.ComLogDAO;
import com.fish.system.po.ComLog;
import com.fish.vo.Passport;

public abstract class ProcessorCallbackService {
	protected PassCodeDAO passCodeDAO;
	protected PassPortCodeDAO passPortCodeDAO;
	protected PassEventDAO passEventDAO;
	protected ComLogDAO comLogDAO;
	
	public boolean callback(PassCode passCode, Passport passport, PassEvent passEvent) {
		if (passport.isStatusSuccess()) {
			return successExecute(passCode, passport);
		} else {
			errorExecute(passCode, passport, passEvent);
			return false;
		}
	}
	
	protected abstract boolean successExecute(PassCode passCode, Passport passport);
	
	protected abstract boolean errorExecute(PassCode passCode, Passport passport, PassEvent passEvent);
	
	protected void addComLog(PassCode passCode, String logContent, String logName) {
		ComLog log = new ComLog();
		log.setObjectType("PASS_CODE");
		log.setParentId(passCode.getOrderId().toString());
		log.setObjectId(passCode.getCodeId());
		log.setOperatorName("SYSTEM");
		log.setLogType("SYSTEM");
		log.setLogName(logName);
		log.setContent(logContent);
		//comLogDAO.insert(log);
	}

	public void setPassCodeDAO(PassCodeDAO passCodeDAO) {
		this.passCodeDAO = passCodeDAO;
	}

	public void setPassPortCodeDAO(PassPortCodeDAO passPortCodeDAO) {
		this.passPortCodeDAO = passPortCodeDAO;
	}

	public void setPassEventDAO(PassEventDAO passEventDAO) {
		this.passEventDAO = passEventDAO;
	}
	
	public void setComLogDAO(ComLogDAO comLogDAO) {
		this.comLogDAO = comLogDAO;
	}
}
